<template>
	<view>
		<view>
			<uni-search :hascity='false' :show="true" @confirm="search"></uni-search>
		</view>
		<view>
			<uni-section type="line" title="热门目的地"></uni-section>
			<view class="address" v-for='item in addsArr' :key='item' @click="goAddress(item)">
				{{item}}
			</view>
		</view>
	</view>
</template>

<script>
	import uniSearch from "@/components/search/search.vue";
	import uniSection from '@/components/uni-section/uni-section.vue'
	export default{
		components: {
			uniSearch,
			uniSection
		},
		data() {
			return {
				params: {
					type:'',
					destination:''
				},
				addsArr:[]
			}
		},
		onLoad(options){
			uni.setNavigationBarTitle({
				title:options.text
			});
			this.params.type = options.text?options.text:'';
			this.getDestination();
			
			
		},
		methods:{
			search(){
				console.log('搜索')
			},
			goAddress(content){
				uni.navigateTo({
					url:'/pages/destination/destination_s?text=' + content
				})
			},
			getDestination(){
				var a = uniCloud.callFunction({
					name:"getDestination",
					data:this.params
				})
				.then(res=>{
					if(res && res.result && res.result.data){
						this.addsArr = res.result.data.destination
					}
				})
				.catch((err)=>{
					uni.showModal({
						content: `调用云函数失败，错误信息为：${err.message}`,
						showCancel: true
					})
				})
			}
		}
	}
</script>

<style>
	.address{
		border: 1px solid #e0e0e0;
		display: inline-block;
		text-align: center;
		width:23%;
		margin:1%;
		box-sizing:border-box
	}
</style>
